package com.ruiysoft.crm.mapper;

import com.ruiysoft.crm.entity.FsDirectory;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruiysoft.crm.entity.FsDirectoryEx;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 分机号和网关，关联表 Mapper 接口
 * </p>
 *
 * @author jobob
 * @since 2020-03-04
 */
public interface FsDirectoryMapper extends BaseMapper<FsDirectory> {

    @Select("SELECT\n" +
            "\tfs_directory.*, fs_gateway. NAME AS gatewayName\n" +
            "FROM\n" +
            "\tfs_directory\n" +
            "LEFT JOIN fs_gateway ON fs_directory.gatewayId = fs_gateway.id\n" +
            "WHERE\n" +
            "\tfs_directory.enterpriseCode = #{enterpriseCode}\n" +
            "ORDER BY\n" +
            "\tfs_directory.extention")
    List<FsDirectoryEx> listLeftJoinGateWay(@Param("enterpriseCode") String arg0);

    @Select("SELECT\n" +
            "\t*\n" +
            "FROM\n" +
            "\tfs_directory\n" +
            "LEFT JOIN fs_gateway ON fs_directory.gatewayId = fs_gateway.id\n" +
            "WHERE\n" +
            "\tfs_directory.id = #{fsDirectoryId}")
    FsDirectoryEx getByIdLeftJoinGateWay(@Param("fsDirectoryId") Integer arg0);
}
